package no.runeway;

import java.io.File;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;

public class JAXBMarshaller {

	public static void outputValidXmlObjectToXmlFile(Object o, String filename)
			throws JAXBException {

		JAXBContext context = JAXBContext.newInstance(o.getClass());
		Marshaller m = context.createMarshaller();
		m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
		m.marshal(o, new File(filename));
		System.out.println("XML file written to " + filename);
	}
}
